package tomasulo.component;

import tomasulo.Driver;

public class Register {

	private String name = null;
	private String station = null;
	private float value = 0;
	
	public Register(String name) {
		this.name = name;
	}
	
	public String getName() {
		return name;
	}

	public void checkCDB(int tick) {
//		System.out.println(name);
		Float tmp = Driver.getCDB(station);
		if (tmp != null) {
			value = tmp;
			station = null;
		}
	}
	
	public boolean isReady() {
		return (station == null);
	}
	
	public void setStation(String station) {
		this.station = station;
	}
	
	public String getStation() {
		return station;
	}

	public void setValue(float value) {
		this.station = null;
		this.value = value;
	}
	
	public float getValue() {
		return value;
	}
	
	public void copyFromFU(int idx) {
		Register r = Driver.getFU().get(idx);
		if (r.isReady())
			this.setValue(r.getValue());
		else
			this.setStation(r.getStation());
	}

	public void reset() {
		// TODO Auto-generated method stub
		station = null;
		value = 0;
	}
	
}
